<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>济宁消防车辆人员出入管理系统</title>
<link rel="stylesheet" href="themes/default/easyui.css" />
<link rel="stylesheet" href="themes/icon.css" />
<link rel="stylesheet" href="css/main.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
</head>
<body>
	<div id="content">
		<form method="post" id="search_car_form" action="record/car/export">
			<table id="search_pc" title="车辆出入记录查询">
				<tr>
					<td>&nbsp;时间：<input type="text" id="beginTime"
						class="easyui-datetimebox" name="beginTime" />~ <input
						type="text" id="finalTime" class="easyui-datetimebox"
						name="finalTime" />&nbsp;车牌号：<input type="text" id="carLicense"
						name="carLicense">&nbsp;机构：<input id="orgId" name="orgId"
						class="easyui-combotree"
						data-options="url:'organization/list',method:'get',valueField:'id',textField:'name',required:true">&nbsp;<a
						href="javascript:searchCarRecord();" class="easyui-linkbutton"
						data-options="iconCls:'icon-search'">查 询</a>&nbsp; <a
						href="javascript:exportCarRecord();" class="easyui-linkbutton"
						id="btn_export" data-options="iconCls:'icon-save'">导 出</a>
						
					</td>
				</tr>
			</table>
		</form>

		<table id="car_rc_dg" title="车辆出入记录"
			data-options="fit:false,fitColumns:true,rownumbers:true,idField:'id',pagination:true,url:'record/car/list',method:'get',pageSize:20,onBeforeLoad:beforeCarRecordListLoad">
			<thead>
				<tr>
					<th data-options="field:'id',hidden:true">ID</th>
					<th data-options="field:'license',width:1">车牌号</th>
					<th data-options="field:'type',width:1">类型</th>
					<th data-options="field:'date',width:3,align:'center'">时间</th>
					<th data-options="field:'masterName',width:1">车主</th>
					<th data-options="field:'phone',width:1">车主手机</th>
				</tr>
			</thead>
		</table>

		<script type="text/javascript">
			$(function() {
				var now = new Date();
				now.setDate(new Date().getDate() - 7);
				$('#beginTime').datetimebox({
					value : now.Format("yyyy-MM-dd hh:mm:ss"),
					required : true,
					showSeconds : true
				});
				$('#finalTime').datetimebox({
					value : new Date().Format("yyyy-MM-dd hh:mm:ss"),
					required : true,
					showSeconds : true
				});
				var corgtreeIsOk=false;//机构树加载完成后才能加载数据
				var corgtree = $('#search_car_form #search_pc #orgId').combotree({
					onLoadSuccess:function(node, data){
						corgtree.combotree("setValue",data[0].id);
						corgtreeIsOk=true;
						$('#car_rc_dg').datagrid('load');
					}
				});
				
				beforeCarRecordListLoad = function(p) {
					if(!corgtreeIsOk){
						return false;//机构树加载完成后才能加载数据
					}
					var beginTime = $('#beginTime').datetimebox('getValue');
					var finalTime = $('#finalTime').datetimebox('getValue');
					var carLicense = $('#carLicense').val();
					var orgId = corgtree.combotree("getValue");
					p.orgId=orgId;
					p.beginTime = beginTime;
					p.finalTime = finalTime;
					p.carLicense = carLicense;
				}

				var pager = $('#car_rc_dg').datagrid().datagrid('getPager'); // get the pager of datagrid
				pager.pagination({
					pageSize : 20,
					beforePageText : "第",
					afterPageText : "条",
					displayMsg : "第 {from} 到 {to} 条，共 {total} 条"
				});
				
				
				
			});
	
			function searchCarRecord() {
				$('#car_rc_dg').datagrid('reload');
			}

			function exportCarRecord() {
				var form = $('#search_car_form').form('submit');
			}
		</script>
	</div>
</body>
</html>
